<script type="text/javascript">
	function doSearchCmsInstructor(value) {
		
	}
	
	//表格查询  
	function reloadCmsInstructor() {
		var params = cmsInstructor_list.datagrid('options').queryParams; //先取得 datagrid 的查询参数  
		printLog(params);
		cmsInstructor_list.datagrid('reload'); //设置好查询参数 reload 一下就可以了  
		cmsInstructor_list.datagrid('unselectAll');
		cmsInstructor_list.datagrid('uncheckAll');
	}


	function addCmsInstructor() {
// 		createFromWindow("新增信息", "cmsInstructor.do?editCmsInstructor", "cmsInstructor.do?saveCmsInstructor",
// 				function(data) {
// 					reloadCmsInstructor();
// 				});
		createFromWindowOptions({
			title:"新增信息",
			maximizable:true,
			width:document.body.clientWidth,
			height:document.body.clientHeight,
			href:"cmsInstructor.do?editCmsInstructor",
			callback:function(d) {
				var rowData2 = d.form("getData");
				var ckData = CKEDITOR.instances.cmsInstructorResume.getData();
				var formData = d.form("getData");
				formData.resume = ckData;
				$.ajax({
	           	  type: 'POST',
	           	  url: "cmsInstructor.do?saveCmsInstructor",
	              dataType : 'json',  
	           	  data: formData,
	           	  success: function(data) {
	           		  showMsg(data.msg);
	           		  if(data.success) {
	           			reloadCmsInstructor();
		           	  }
	           	  },
		          error:function(data,textstatus){  
		        	  printLog(data);
		        	  showMsg('请求异常');
		           }  
	           	});
				
			},
			enableSaveButton:true
		});
	}
	
	function deleteCmsInstructor() {
		var rows = cmsInstructor_list.datagrid('getChecked');
	    if (rows&&rows.length>0){
	        $.messager.confirm('询问','你确认要删除吗?',function(r){
	            if (r){
	            	var ids = "";
	            	for(var i=0; i<rows.length; i++){
	            		ids += rows[i].id+",";
	            	}
	                $.post('cmsInstructor.do?deleteCmsInstructorItems',{ids:ids},function(result){
	                    if (result.success){
	                    	reloadCmsInstructor();    
	                    }
	                    showMsg(result.msg);
	                },'json');
	            }
	        });
	    }else {
	    	showMsg("请选择操作记录.");
	    }
	}

	function editCmsInstructor() {
		var rows = cmsInstructor_list.datagrid('getChecked');
		printLog(rows);
		if (rows&&rows.length>0) {
			if(rows.length>1) {
				showMsg('请选择一条操作记录.');
				return;
			}
// 			createFromWindow("编辑信息", "cmsInstructor.do?editCmsInstructor&cmsInstructorId=" + rows[0].id,
// 					"cmsInstructor.do?saveCmsInstructor", function(data) {
// 						reloadCmsInstructor();
// 					},true);

			createFromWindowOptions({
				title:"编辑信息",
				maximizable:true,
				width:document.body.clientWidth,
				height:document.body.clientHeight,
				href:"cmsInstructor.do?editCmsInstructor&cmsInstructorId=" + rows[0].id,
				callback:function(d) {
					var rowData2 = d.form("getData");
					var ckData = CKEDITOR.instances.cmsInstructorResume.getData();
					var formData = d.form("getData");
					formData.resume = ckData;
					$.ajax({
		           	  type: 'POST',
		           	  url: "cmsInstructor.do?saveCmsInstructor",
		              dataType : 'json',  
		           	  data: formData,
		           	  success: function(data) {
		           		  showMsg(data.msg);
		           		  if(data.success) {
		           			reloadCmsInstructor();
			           	  }
		           	  },
			          error:function(data,textstatus){  
			        	  printLog(data);
			        	  showMsg('请求异常');
			           }  
		           	});
					
				},
				enableSaveButton:true
			});
		} else {
			showMsg('请选择操作记录.');
		}

	}
	
	
	function clearCmsInstructorSearch() {
		setGridSearchParams('cmsInstructor_list','cmsInstructorSearchForm',true,reloadCmsInstructor);
	}
	
	//根据条件查询
	function cmsInstructorSearch() {
		setGridSearchParams('cmsInstructor_list','cmsInstructorSearchForm',false,reloadCmsInstructor);
	}
	
	function onDblClickCmsInstructorRow(rowIndex, rowData) {
// 		createFromWindow("编辑信息", "cmsInstructor.do?editCmsInstructor&cmsInstructorId=" + rowData.id,
// 					"cmsInstructor.do?saveCmsInstructor", function(data) {
// 						reloadCmsInstructor();
// 					},true);
		
		createFromWindowOptions({
			title:"编辑信息",
			maximizable:true,
			width:document.body.clientWidth,
			height:document.body.clientHeight,
			href:"cmsInstructor.do?editCmsInstructor&cmsInstructorId=" + rowData.id,
			callback:function(d) {
				var rowData2 = d.form("getData");
				var ckData = CKEDITOR.instances.cmsInstructorResume.getData();
				var formData = d.form("getData");
				formData.resume = ckData;
				$.ajax({
	           	  type: 'POST',
	           	  url: "cmsInstructor.do?saveCmsInstructor",
	              dataType : 'json',  
	           	  data: formData,
	           	  success: function(data) {
	           		  showMsg(data.msg);
	           		  if(data.success) {
	           			reloadCmsInstructor();
		           	  }
	           	  },
		          error:function(data,textstatus){  
		        	  printLog(data);
		        	  showMsg('请求异常');
		           }  
	           	});
				
			},
			enableSaveButton:true
		});
	}
</script>


<div class="easyui-layout" data-options="fit:true">
	<div data-options="region:'center',border:false">
		<@eu.datagrid id="cmsInstructor_list" toolbar="#cmsInstructorlist_search" idField="id"  url="cmsInstructor.do?loadList" rownumbers="true" onDblClickRow="onDblClickCmsInstructorRow(rowIndex, rowData)"
			 item="com.xdtech.cms.vo.CmsInstructorItem"/>
		
		<div id="cmsInstructorlist_search">
			<div style="margin-bottom:5px;padding-left:5px;margin-top: 5px;">
				<form id="cmsInstructorSearchForm">
					<!-- 防止form表单里只有一个text元素时候，按enter键自动提交问题 -->
					<input style="display:none" />
					<table>
						<tr>
							<td>姓名：</td>
							<td><input class="easyui-validatebox textbox" name="name" style="width: 150px"/></td>
							<td>导师等级：</td>
							<td><@eu.comboBox name="level" url="common.do?loadComboBox&key=CMS_MENTOR_LEVEL" /></td>
							<td>导师类别：</td>
							<td><@eu.comboBox name="instructorType" url="common.do?loadComboBox&key=CMS_MENTOR_TYPE" /></td>
							<td>技术领域：</td>
							<td><input class="easyui-validatebox textbox" name="technicalField" style="width: 150px"/></td>
							
						</tr>
						<tr>
							<td>辅导特长：</td>
							<td><@eu.comboBox name="coachingSkills" url="common.do?loadComboBox&key=YON" /></td>
							<td>所属机构：</td>
							<td><@eu.comboBox name="organization" url="common.do?loadComboBox&key=YON" /></td>
							<td>行政市区：</td>
							<td></td>
							<td>所属单位：</td>
							<td><input class="easyui-validatebox textbox" name="company" style="width: 150px"/></td>
							<td>
								<@eu.linkbutton showName="查询" iconCls="icon-search" onclick="cmsInstructorSearch()"/>
	 					 		<@eu.linkbutton showName="清空" iconCls="icon-clear" onclick="clearCmsInstructorSearch()"/>
 					 		</td>
						</tr>
					</table>
				</form>
				
			</div>
			<div id="cmsInstructor_toolbar" style="height: auto">
				<@eu.linkbutton showName="新增" shiro="cms:cmsInstructor:add" iconCls="icon-add" onclick="addCmsInstructor()"/>
				<@eu.linkbutton showName="删除" shiro="cms:cmsInstructor:delete" iconCls="icon-remove" onclick="deleteCmsInstructor()"/>
				<@eu.linkbutton showName="编辑" shiro="cms:cmsInstructor:edit" iconCls="icon-edit" onclick="editCmsInstructor()"/>
				<@eu.linkbutton showName="刷新" shiro="cms:cmsInstructor:refresh" iconCls="icon-reload" onclick="reloadCmsInstructor()"/>
			</div>
		</div>
	</div>
</div>